package com.augurit.smartform.display;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.augurit.smartform.constant.TypeConstant;

@Component
public class TemplateSelector {
	private final Map<String,String> templateMap=new HashMap<String,String>();
	
	public TemplateSelector(){
		registerTemplate(TypeConstant.TEXTFIELD, "html-textfield.ftl");
		registerTemplate(TypeConstant.HIDDEN, "html-hidden.ftl");
		registerTemplate(TypeConstant.TEXTAREA, "html-textarea.ftl");
		registerTemplate(TypeConstant.CHECKBOX, "html-checkbox.ftl");
		registerTemplate(TypeConstant.CHECKBOXLIST, "struts-checkboxlist.ftl");
		registerTemplate(TypeConstant.RADIO, "html-radio.ftl");
//		registerTemplate(TypeConstant.SELECT, "html-select.ftl");
		registerTemplate(TypeConstant.SELECT, "struts-select.ftl");
//		registerTemplate(TypeConstant.LIST, "html-list.ftl");
		registerTemplate(TypeConstant.LIST, "struts-list.ftl");
		registerTemplate(TypeConstant.DATE, "html-date.ftl");
		registerTemplate(TypeConstant.NUMBER, "html-number.ftl");
		registerTemplate(TypeConstant.BUTTON, "html-button.ftl");
		registerTemplate(TypeConstant.DIV, "html-div.ftl");
		
		/**
		 * 工作流相关
		 */
		registerTemplate(TypeConstant.WF_BUTTON, "wf-button.ftl");
		registerTemplate(TypeConstant.WF_DATE, "wf-date.ftl");
		registerTemplate(TypeConstant.WF_OPINION, "wf-opinion.ftl");
		registerTemplate(TypeConstant.WF_TEXTAREA, "wf-textarea.ftl");
		registerTemplate(TypeConstant.WF_TEXTFIELD, "wf-textfield.ftl");
		
		/**
		 * OA相关
		 */
		registerTemplate(TypeConstant.OA_SEND, "oa-send.ftl");
		registerTemplate(TypeConstant.OA_JUDGMENT, "oa-judgment.ftl");
		registerTemplate(TypeConstant.OA_CREATENO, "oa-createno.ftl");
	}
	
	/**
	 * 注册模板
	 * @param type
	 * @param templateName
	 */
	public void registerTemplate(String type,String templateName){
		this.templateMap.put(type, templateName);
	}
	
	/**
	 * 取得模板
	 * @param type
	 * @return
	 */
	public String getTemplate(String type){
		return this.templateMap.get(type);
	}
}
